package com.example.webdemo;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class WelcomeController {

    // 处理 GET 请求，返回欢迎页面
    @GetMapping("/")
    public String welcomePage() {
        return "welcome";
    }

    // 处理 POST 请求，显示个性化的欢迎页面
    @PostMapping("/greet")
    public String greetUser(@RequestParam("name") String name, Model model) {
        model.addAttribute("name", name);
        return "greet";
    }
}